package com.navidove.appspotlight.model.bo;

import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;

@Entity
@Table(name = "sys_user")
public class SysUser implements java.io.Serializable {

	private static final long serialVersionUID = 1L;

	private Long id;
	private String username;
	private String displayName;
	private String pwd;
	private String email;
	private Boolean isSupervisor = Boolean.FALSE;
	private Boolean enable;
	private Date crtAt;
	private Date updAt;

	@Id
	@SequenceGenerator(name = "generator", sequenceName = "sys_user_id_seq", allocationSize = 1)
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "generator")
	public Long getId() {
		return this.id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@Column(name = "username", nullable = false, length = 20)
	public String getUsername() {
		return this.username;
	}

	public void setUsername(String username) {
		if (username != null) username = username.toLowerCase();
		this.username = username;
	}

	@Column(name = "display_name", nullable = false, length = 50)
	public String getDisplayName() {
		return this.displayName;
	}

	public void setDisplayName(String displayName) {
		this.displayName = displayName;
	}

	@Column(name = "pwd", nullable = false, length = 32)
	public String getPwd() {
		return this.pwd;
	}

	public void setPwd(String pwd) {
		this.pwd = pwd;
	}

	@Column(name = "email", nullable = false, length = 100)
	public String getEmail() {
		return this.email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	@Column(name = "is_supervisor", nullable = false)
	public Boolean getIsSupervisor() {
		return this.isSupervisor;
	}

	public void setIsSupervisor(Boolean isSupervisor) {
		this.isSupervisor = isSupervisor;
	}

	@Column(name = "enable", nullable = false)
	public Boolean getEnable() {
		return this.enable;
	}

	public void setEnable(Boolean enable) {
		this.enable = enable;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "crt_at", length = 29)
	public Date getCrtAt() {
		return this.crtAt;
	}

	public void setCrtAt(Date crtAt) {
		this.crtAt = crtAt;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "upd_at", length = 29)
	public Date getUpdAt() {
		return this.updAt;
	}

	public void setUpdAt(Date updAt) {
		this.updAt = updAt;
	}

	/**
	 * @see java.lang.Object#toString
	 * @return String
	 */
	public String toString() {
		return new ToStringBuilder(this).append("id", getId()).toString();

	}

	/**
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}
		if (obj == this) {
			return true;
		}
		if (obj.getClass() != getClass()) {
			return false;
		}
		SysUser rhs = (SysUser) obj;

		return new EqualsBuilder().append(getId(), rhs.getId()).isEquals();
	}

	/**
	 * @see java.lang.Object#hashCode()
	 */
	public int hashCode() {
		return new HashCodeBuilder(17, 37).append(getId()).toHashCode();
	}

}
